package com.lmy;

import com.lmy.springboot.bean.Furn;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j  //lombok提供的日志输出注解
public class HiController {

    //需求,website属性值从application.properties文件获取
    @Value("${my.website}")
    private String website;

    //装配到HiController
    @Autowired
    private Furn furn;

    @RequestMapping("/hi")
    @ResponseBody
    public String hi() {
        return "hi~,Spring Boot!" + website;
    }

    @RequestMapping("/furn")
    @ResponseBody
    public Furn furn() {
//        使用slf4j日志输出
        //可以直接输出
        log.info("furn-" + furn);
        //可以占位符输出
        log.info("furn={}, website={}", furn, this.website);
        return this.furn;
    }
}
